package vip.liux.contracts.repositories.pay;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.ListCrudRepository;
import org.springframework.data.repository.ListPagingAndSortingRepository;
import org.springframework.data.repository.NoRepositoryBean;
import vip.liux.contracts.models.pay.PayTransfer;
import vip.liux.contracts.shared.enums.pay.PayTransferStatus;

import java.time.LocalDateTime;
import java.util.List;

@NoRepositoryBean
public interface PayTransferRepository extends ListPagingAndSortingRepository<PayTransfer, Long>, ListCrudRepository<PayTransfer, Long> {

    PayTransfer findByAppIdAndMerchantTransferId(Long appId, String merchantTransferId);

    PayTransfer findByAppIdAndTransferNo(Long appId, String transferNo);

    PayTransfer findByTransferNo(String transferNo);

    int updateByIdAndStatus(Long id, PayTransferStatus whereStatus, PayTransferStatus status);

    int updateByIdAndStatus(Long id, PayTransferStatus whereStatus, PayTransferStatus status, String channelPackageInfo);

    int updateByIdAndStatus(Long id, List<PayTransferStatus> whereStatus, PayTransferStatus status, LocalDateTime successTime, String channelTransferNo, String channelNotifyData);

    int updateByIdAndStatus(Long id, List<PayTransferStatus> whereStatus, PayTransferStatus status, String channelTransferNo, String channelNotifyData, String channelErrorCode, String channelErrorMsg);

    List<PayTransfer> findByStatusIn(List<PayTransferStatus> status);

    Page<PayTransfer> findPage(String transferNo, Long appId, String channelCode, String merchantTransferId, PayTransferStatus status, String userName, String userAccount, String channelTransferNo, LocalDateTime start, LocalDateTime end, Pageable page);
}